jobject alternative in system.text.json

132

jobject alternative in system.text.json -

public class MyDTO
{
    public JsonElement ExtractedData {get;set;} = JsonExtensions.Null;
}

public static class JsonExtensions
{
    static readonly JsonElement nullElement = CreateNull();

    public static JsonElement Null => nullElement;

    static JsonElement CreateNull()
    {
        using var doc = JsonDocument.Parse("null");
        return doc.RootElement.Clone();
    }
}

Comments

Submit
0 Comments